import axios from './axios'
/**
 * 封装了Promise版本的定时器
 * @param delay 延迟时间
 * @returns Promise
 */
async function wait(delay) {
  return new Promise((resolve) => setTimeout(resolve, delay))
}
const API = {
  login(data) {
    return axios.post('/login', data)
  },
  logout() {
    return axios.post('/logout')
  },
  getUserInfo() {
    return axios.get('/users/info')
  },
  getUserList(params) {
    return axios.get('/users', {
      params,
    })
  },
  getUser(id) {
    return axios.get(`/users/${id}`)
  },
  createUser(data) {
    return axios.post('/users', data)
  },
  updateUser(id, data) {
    return axios.put(`/users/${id}`, data)
  },
  deleteUser(id) {
    return axios.delete(`/users/${id}`)
  },
  getRouter() {
    return axios.get('/routerData')
  },
}

export default API
